package com.ncmmall.api.apis.mall;


import com.ncmmall.api.apis.service.Result;
import com.ncmmall.api.params.GoodsCommentDTO;
import com.ncmmall.api.params.GoodsCommentImageDTO;
import com.ncmmall.api.security.Securitys;
import com.ncmmall.application.business.goods.GoodsApplication;
import com.ncmmall.application.business.member.MemberApplication;
import com.ncmmall.application.business.order.OrderApplication;
import com.feijin.commons.lang.Requires;
import com.ncmmall.domain.business.distribution.DistributionGoodsAssign;
import com.ncmmall.domain.business.distribution.Distributor;
import com.ncmmall.domain.business.distribution.QDistributor;
import com.ncmmall.domain.business.goods.Goods;
import com.ncmmall.domain.business.goods.QGoods;
import com.ncmmall.domain.business.goods.comment.GoodsComment;
import com.ncmmall.domain.business.goods.comment.GoodsCommentImage;
import com.ncmmall.domain.business.goods.comment.QGoodsComment;
import com.ncmmall.domain.business.goods.image.GoodsImage;
import com.ncmmall.domain.business.marketing.gift.GiftActivity;
import com.ncmmall.domain.business.marketing.gift.GiftChannel;
import com.ncmmall.domain.business.marketing.gift.GiftScope;
import com.ncmmall.domain.business.marketing.gift.QGiftActivity;
import com.ncmmall.domain.business.marketing.gift.QGiftChannel;
import com.ncmmall.domain.business.marketing.gift.QGiftScope;
import com.ncmmall.domain.business.order.OrderDetail;
import com.ncmmall.domain.business.order.QOrderDetail;
import com.ncmmall.domain.business.order.groupbooking.GroupBooking;
import com.ncmmall.domain.business.order.groupbooking.GroupBookingOrder;
import com.ncmmall.domain.business.order.groupbooking.QGroupBookingOrder;
import com.ncmmall.domain.security.user.WebUser;
import com.ncmmall.querychannel.QueryPage;
import com.ncmmall.querychannel.QueryPageRequest;
import com.ncmmall.querychannel.service.QueryChannelService;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author linxs
 * 商品接口
 */
@RestController
@RequestMapping(value = "/goods")
@Slf4j
public class GoodsApi {

    @Autowired
    private GoodsApplication goodsApplication;

    @Autowired
    private OrderApplication orderApplication;

    @Autowired
    private QueryChannelService queryChannelService;

    @Autowired
    private MemberApplication memberApplication;

    @Value("${store.domain}")
    private String storeDomain;

    /**
     * 拼团列表
     */
    @RequestMapping(value = "/groupBookings", method = RequestMethod.GET)
    @ResponseBody
    public Result groupBookings(HttpServletRequest request, @RequestParam(defaultValue = "1") int pageNo, @RequestParam(defaultValue = "10") int pageSize, @RequestParam(defaultValue = "1") int orderType, @RequestParam(defaultValue = "1") int orderBy) {
        Result result = new Result();
        try {

            QueryPageRequest pageRequest = new QueryPageRequest().setPageNo(pageNo).setPageSize(pageSize);
            Map<String, Object> map = new HashMap<>();

            String hql = "select g from Goods g where g.isSupplier = 0 and g.marketingType = 4 and g.status = 3 and g.groupBookingStatus in (3,5,6) ";
            QueryPage<Goods> page = queryChannelService.findPage(builderGroupBookingSql(hql, orderType, orderBy, request, map), pageRequest.setParams(map), Goods.class);
            for (Goods goods : page.getResult()) {
                goods.setDefaultImage(storeDomain + "/uploads/" + goods.getDefaultImage());
            }

            return result.ok().inject(page);

        } catch (Exception e) {

            log.error("[分类商品列表获取数据异常]", e);
            return result.fail().setMsg("网络连接失败");
        }

    }

    /**
     * 预售列表
     */
    @RequestMapping(value = "/presells", method = RequestMethod.GET)
    @ResponseBody
    public Result presells(HttpServletRequest request, @RequestParam(defaultValue = "1") int pageNo, @RequestParam(defaultValue = "10") int pageSize, @RequestParam(defaultValue = "1") int orderType, @RequestParam(defaultValue = "1") int orderBy) {
        Result result = new Result();
        try {

            QueryPageRequest pageRequest = new QueryPageRequest().setPageNo(pageNo).setPageSize(pageSize);
            Map<String, Object> map = new HashMap<>();

            String hql = "select g from Goods g where g.isSupplier=0 and g.marketingType = 3 and g.status = 3 and g.presellStatus in (5,6,7,8) ";
            QueryPage<Goods> page = queryChannelService.findPage(builderPresellSql(hql, orderType, orderBy, request, map), pageRequest.setParams(map), Goods.class);
            for (Goods goods : page.getResult()) {
                goods.setDefaultImage(storeDomain + "/uploads/" + goods.getDefaultImage());
            }

            return result.ok().inject(page);

        } catch (Exception e) {

            log.error("[分类商品列表获取数据异常]", e);
            return result.fail().setMsg("网络连接失败");
        }

    }

    /**
     * 秒杀场次商品列表
     */
    @RequestMapping(value = "/seckills", method = RequestMethod.GET)
    @ResponseBody
    public Result seckills(HttpServletRequest request, @RequestParam("id") long id, @RequestParam(defaultValue = "1") int pageNo, @RequestParam(defaultValue = "10") int pageSize, @RequestParam(defaultValue = "1") int orderType, @RequestParam(defaultValue = "1") int orderBy) {
        Result result = new Result();
        try {

            QueryPageRequest pageRequest = new QueryPageRequest().setPageNo(pageNo).setPageSize(pageSize);
            Map<String, Object> map = new HashMap<>();

            String hql = "select g from Goods g where g.isSupplier=0 and g.seckillSession.id = :id and g.status = 3 and g.seckillStatus in (3,5,6) ";
            map.put("id", id);
            QueryPage<Goods> page = queryChannelService.findPage(builderSeckillSql(hql, orderType, orderBy, request, map), pageRequest.setParams(map), Goods.class);
            for (Goods goods : page.getResult()) {
                goods.setDefaultImage(storeDomain + "/uploads/" + goods.getDefaultImage());
            }

            return result.ok().inject(page);

        } catch (Exception e) {
            log.error("[分类商品列表获取数据异常]", e);
            return result.fail().setMsg("网络连接失败");
        }

    }

    /**
     * 特价活动商品列表
     */
    @RequestMapping(value = "/bargains", method = RequestMethod.GET)
    public Result bargains(HttpServletRequest request, @RequestParam(defaultValue = "1") int pageNo, @RequestParam(defaultValue = "10") int pageSize, @RequestParam(defaultValue = "1") int orderType, @RequestParam(defaultValue = "1") int orderBy) {

        Result result = new Result();
        try {
            QueryPageRequest pageRequest = new QueryPageRequest().setPageNo(pageNo).setPageSize(pageSize);
            Map<String, Object> map = new HashMap<>();

            String hql = "select g from Goods g where g.isSupplier=0 and g.marketingType = 1 and g.status = 3 and g.bargainStatus in (3,5,6) ";
            QueryPage<Goods> page = queryChannelService.findPage(builderBargainSql(hql, orderType, orderBy, request, map), pageRequest.setParams(map), Goods.class);
            for (Goods goods : page.getResult()) {
                goods.setDefaultImage(storeDomain + "/uploads/" + goods.getDefaultImage());
            }
            return result.ok().inject(page);
        } catch (Exception e) {
            log.error("[分类商品列表获取数据异常]", e);
            return result.fail().setMsg("网络连接失败");
        }

    }

    /**
     * @param orderBy 1、综合；2、最新；3、价格；4、销量；
     * @param order   1、desc；2、asc
     */
    private String builderBargainSql(String hql, int orderBy, int order, HttpServletRequest request, Map<String, Object> map) {

        if (!Strings.isNullOrEmpty(request.getParameter("maxPrice")) && !Strings.isNullOrEmpty(request.getParameter("minPrice"))) {
            hql += " and g.bargainPrice <= :max and g.bargainPrice >= :min ";
            map.put("max", Double.parseDouble(request.getParameter("maxPrice")));
            map.put("min", Double.parseDouble(request.getParameter("minPrice")));
        }

        if (orderBy == 1) {
            hql += " order by g.createTime " + (order == 1 ? "desc" : "asc");
        }

        if (orderBy == 2) {
            hql += " order by g.createTime " + (order == 1 ? "desc" : "asc");
        }

        if (orderBy == 3) {
            hql += " order by g.bargainPrice " + (order == 1 ? "desc" : "asc");
        }

        if (orderBy == 4) {
            hql += " order by g.salesVolume " + (order == 1 ? "desc" : "asc");
        }

        return hql;
    }

    private String builderPresellSql(String hql, int orderBy, int order, HttpServletRequest request, Map<String, Object> map) {

        if (!Strings.isNullOrEmpty(request.getParameter("maxPrice")) && !Strings.isNullOrEmpty(request.getParameter("minPrice"))) {
            hql += " and g.presellPrice <= :max and g.presellPrice >= :min ";
            map.put("max", Double.parseDouble(request.getParameter("maxPrice")));
            map.put("min", Double.parseDouble(request.getParameter("minPrice")));
        }

        if (orderBy == 1) {
            hql += " order by g.createTime " + (order == 1 ? "desc" : "asc");
        }

        if (orderBy == 2) {
            hql += " order by g.createTime " + (order == 1 ? "desc" : "asc");
        }

        if (orderBy == 3) {
            hql += " order by g.presellPrice " + (order == 1 ? "desc" : "asc");
        }

        if (orderBy == 4) {
            hql += " order by g.salesVolume " + (order == 1 ? "desc" : "asc");
        }

        return hql;
    }

    private String builderSeckillSql(String hql, int orderBy, int order, HttpServletRequest request, Map<String, Object> map) {

        if (!Strings.isNullOrEmpty(request.getParameter("maxPrice")) && !Strings.isNullOrEmpty(request.getParameter("minPrice"))) {
            hql += " and g.seckillPrice <= :max and g.seckillPrice >= :min ";
            map.put("max", Double.parseDouble(request.getParameter("maxPrice")));
            map.put("min", Double.parseDouble(request.getParameter("minPrice")));

        }

        if (orderBy == 1) {
            hql += " order by g.createTime " + (order == 1 ? "desc" : "asc");
        }

        if (orderBy == 2) {
            hql += " order by g.createTime " + (order == 1 ? "desc" : "asc");
        }

        if (orderBy == 3) {
            hql += " order by g.seckillPrice " + (order == 1 ? "desc" : "asc");
        }

        if (orderBy == 4) {
            hql += " order by g.salesVolume " + (order == 1 ? "desc" : "asc");
        }

        return hql;
    }

    private String builderGroupBookingSql(String hql, int orderBy, int order, HttpServletRequest request, Map<String, Object> map) {

        if (!Strings.isNullOrEmpty(request.getParameter("maxPrice")) && !Strings.isNullOrEmpty(request.getParameter("minPrice"))) {
            hql += " and g.groupBookingPrice <= :max and g.groupBookingPrice >= :min ";
            map.put("max", Double.parseDouble(request.getParameter("maxPrice")));
            map.put("min", Double.parseDouble(request.getParameter("minPrice")));
        }

        if (orderBy == 1) {
            hql += " order by g.createTime " + (order == 1 ? "desc" : "asc");
        }

        if (orderBy == 2) {
            hql += " order by g.createTime " + (order == 1 ? "desc" : "asc");
        }

        if (orderBy == 3) {
            hql += " order by g.groupBookingPrice " + (order == 1 ? "desc" : "asc");
        }

        if (orderBy == 4) {
            hql += " order by g.salesVolume " + (order == 1 ? "desc" : "asc");
        }

        return hql;
    }

    /**
     * 商品详情
     *
     * @param shareUserId 通过分享海报进入商品详情， 如果用户是没有上级的普通用户，那么用户和分享人形成暂时的绑定关系，绑定时长后台设置
     */
    @RequestMapping(value = "/detail", method = RequestMethod.GET)
    @ResponseBody
    public Result detail(HttpServletRequest request, long id, Long shareUserId) {
        Result result = new Result();
        try {

            Goods goods = queryChannelService.findOne(QGoods.goods.id.eq(id), Goods.class);
            Requires.notNull(goods, "商品不存在");

            for (GoodsImage image : goods.getImages()) {
                image.setName(storeDomain + "/uploads/" + image.getName());
            }

            if (StringUtils.isNotBlank(goods.getDefaultImage())) {
                goods.setDefaultImage(storeDomain + "/uploads/" + goods.getDefaultImage());
            }

            Map<String, Object> data = new HashMap<>();

            UserCoupon userCoupon;

            //收藏状态
            if (Securitys.isLogin(request)) {
                WebUser user = Securitys.user(request);

                userCoupon = new UserCoupon(goods, user, queryChannelService);

                int count = queryChannelService.selectCount("select count(*) from mall_goods_collect where goods_id = :gid and member_id = :mid", ImmutableMap.of("gid", id, "mid", user.getId()));
                goods.setCollect(count > 0);

                //是否是分销商品且上级不为空
                if (user.getFather() != null && user.getFather().getDistributor() != null) {
                    DistributionGoodsAssign ga = queryChannelService.findOne("select d from DistributionGoodsAssign d where d.distributor.id = :did and d.distributionGoods.goods.id = :gid",
                            ImmutableMap.of("did", user.getFather().getDistributor().getId(), "gid", goods.getId()), DistributionGoodsAssign.class);
                    data.put("isDistributionGoods", ga != null);
                    data.put("distributorId", ga == null ? null : user.getFather().getDistributor().getId());
                }

                if (shareUserId != null && user.getFather() == null && user.getDistributor() == null) {
                    Distributor distributor = queryChannelService.findOne(QDistributor.distributor.id.eq(shareUserId), Distributor.class);
                    if (distributor != null) {
                        memberApplication.bindFather(user, distributor.getUser());
                    }
                }
            } else {
                userCoupon = new UserCoupon(goods, null, queryChannelService);
            }

            //评论
            Long commentCount = queryChannelService.findCount(QGoodsComment.goodsComment.goods.id.eq(id).and(QGoodsComment.goodsComment.platformType.eq(0)).and(QGoodsComment.goodsComment.status.eq(2)), GoodsComment.class);
            GoodsComment comment = goodsComments(id);

            List<GiftActivity> giftActivities = Lists.newArrayList();
            giftActivity(goods, giftActivities);


            Map<String, Object> shop = new HashMap<>();
            shop.put("name", Strings.isNullOrEmpty(goods.getMerchant().getShopName()) ? "" : goods.getMerchant().getShopName());
            shop.put("id", goods.getMerchant().getId());
            shop.put("logo", Strings.isNullOrEmpty(goods.getMerchant().getAvatar()) ? "" : storeDomain + "/avatar/" + goods.getMerchant().getAvatar());
            shop.put("selfSupport", goods.getMerchant().getSelfSupport());


            data.put("goods", goods);
            data.put("commentCount", commentCount);
            data.put("comment", comment);
            data.put("serviceTelephone", goods.getMerchant().getMobile());
            data.put("shop", shop);
            data.put("coupons", userCoupon.getNotDraw());
            data.put("drawCoupons", userCoupon.getUsableDraw());
            data.put("gifts", giftActivities);
            data.put("marketingType", goodsApplication.ensureMarketingType(goods));
            data.put("systemTime", System.currentTimeMillis());
            data.put("groupBookings", builderGroupBookings(request, goods));

            return result.ok().inject(data);

        } catch (IllegalArgumentException e) {
            return result.fail().setMsg(e.getMessage());
        } catch (Exception e) {
            log.error("[获取商品详情异常]", e);
            return result.fail().setMsg("网络连接失败");
        }
    }

    /**
     * 商品详情优惠券
     */
    @RequestMapping(value = "/coupons", method = RequestMethod.GET)
    @ResponseBody
    public Result coupons(HttpServletRequest request, long id) {
        Result result = new Result();
        try {

            Goods goods = queryChannelService.findOne(QGoods.goods.id.eq(id), Goods.class);
            Requires.notNull(goods, "商品不存在");

            WebUser user = Securitys.user(request);
            UserCoupon userCoupon = new UserCoupon(goods, user, queryChannelService);

            Map<String, Object> data = new HashMap<>();
            data.put("coupons", userCoupon.getNotDraw());
            data.put("drawCoupons", userCoupon.getDraw());

            return result.ok().inject(data);

        } catch (IllegalArgumentException e) {
            return result.fail().setMsg(e.getMessage());
        } catch (Exception e) {
            log.error("[获取优惠券异常]", e);
            return result.fail().setMsg("获取优惠券异常");
        }
    }

    /**
     * 拼团的记录
     */
    private List<Map<String, Object>> builderGroupBookings(HttpServletRequest request, Goods goods) {

        List<Map<String, Object>> data = Lists.newArrayList();

        if (Securitys.isLogin(request)) {

            WebUser member = Securitys.user(request);
            List<GroupBooking> groupBookings = queryChannelService.findLimit("select g from GroupBooking g where g.status = 1 and g.sku.goods.id = :id ", new QueryPageRequest().setPageSize(2).setParams(ImmutableMap.of("id", goods.getId())), GroupBooking.class);

            for (GroupBooking groupBooking : groupBookings) {
                Map<String, Object> item = new HashMap<>();
                item.put("id", groupBooking.getId());
                item.put("avatar", storeDomain + "/avatar/" + groupBooking.getMember().getAvatar());
                item.put("nickname", groupBooking.getMember().getNickname());
                item.put("groupBookingCondition", groupBooking.getGroupBookingCondition() - groupBooking.getGroupBookingTotal());
                item.put("endTime", groupBooking.getEndTime());
                item.put("specs", groupBooking.getSku().getAttribute1().getName() + " " + (null != groupBooking.getSku().getAttribute2() ? groupBooking.getSku().getAttribute2().getName() : ""));
                item.put("skuId", groupBooking.getSku().getId());

                List<GroupBookingOrder> orders = queryChannelService.findAll(QGroupBookingOrder.groupBookingOrder.groupBooking.eq(groupBooking).and(QGroupBookingOrder.groupBookingOrder.status.in(2, 3)), GroupBookingOrder.class);

                List<Map<String, Object>> detail = Lists.newArrayList();
                for (GroupBookingOrder order : orders) {

                    if (member.getId() == order.getMember().getId()) {
                        continue;
                    }

                    Map<String, Object> orderItem = Maps.newHashMap();
                    orderItem.put("avatar", storeDomain + "/avatar/" + order.getMember().getAvatar());
                    orderItem.put("nickname", order.getMember().getNickname());
                    orderItem.put("type", order.getType());
                    detail.add(orderItem);
                }
                item.put("details", detail);

                data.add(item);
            }

        }

        return data;
    }

    private GoodsComment goodsComments(long id) {
        QueryPageRequest page = new QueryPageRequest();
        page.setPageSize(1);
        page.setParams(ImmutableMap.of("id", id));
        QueryPage<GoodsComment> comments = queryChannelService.findPage("select c from GoodsComment c where c.status = 2 and c.platformType = 0 and c.goods.id = :id order by c.createTime desc ", page, GoodsComment.class);
        GoodsComment comment = comments.getResult().size() > 0 ? comments.getResult().get(0) : null;
        if (null != comment) {
            Securitys.cleanUser(comment.getMember());
            for (GoodsCommentImage image : comment.getImages()) {
                image.setName(storeDomain + "/uploads/" + image.getName());
            }

        }
        return comment;
    }

    /**
     * 赠品活动
     */
    private void giftActivity(Goods goods, List<GiftActivity> giftActivities) {
        //赠品活动
        List<GiftActivity> merchantGiftActivities = queryChannelService.findAll(QGiftActivity.giftActivity.merchant.eq(goods.getMerchant()).and(QGiftActivity.giftActivity.isValidity.eq(2)).and(QGiftActivity.giftActivity.status.eq(1)), GiftActivity.class);
        for (GiftActivity giftActivity : merchantGiftActivities) {
            //是否有设置全部商品可用的赠品活动
            if (giftActivity.getScopeGoodsType() == 1) {
                giftActivities.add(giftActivity);
            }
            //是否有指定当前商品的赠品活动
            if (giftActivity.getScopeGoodsType() == 2) {
                List<GiftScope> scopes = queryChannelService.findAll(QGiftScope.giftScope.merchant.eq(goods.getMerchant()).and(QGiftScope.giftScope.gift.eq(giftActivity)), GiftScope.class);
                for (GiftScope scope : scopes) {
                    if (scope.getGoods().getId() == goods.getId()) {
                        giftActivities.add(giftActivity);
                    }
                }
            }
            //是否有指定当前商品分类的赠品活动
            if (giftActivity.getScopeGoodsType() == 3) {
                List<GiftChannel> channels = queryChannelService.findAll(QGiftChannel.giftChannel.merchant.eq(goods.getMerchant()).and(QGiftChannel.giftChannel.gift.eq(giftActivity)), GiftChannel.class);
                for (GiftChannel channel : channels) {
                    if (goods.getGoodsChannel().getParent().getParent().getId() == channel.getChannel().getId()) {
                        giftActivities.add(giftActivity);
                    }
                }
            }
        }

        for (GiftActivity giftActivity : giftActivities) {
            List<Goods> gifts = queryChannelService.findAll("select g.goods from GiftGoods g where g.gift.id = :id ", ImmutableMap.of("id", giftActivity.getId()), Goods.class);
            if (CollectionUtils.isNotEmpty(gifts)) {
                giftActivity.setGiftGoodses(gifts.stream().map(input -> {
                    Map<String, Object> data = new HashMap<>();
                    data.put("id", input.getId());
                    data.put("name", input.getName());
                    data.put("defaultImage", storeDomain + "/uploads/" + input.getDefaultImage());
                    return data;
                }).collect(Collectors.toList()));
            }
        }
    }

    /**
     * 商品评价
     */
    @RequestMapping(value = "/comment", method = RequestMethod.POST)
    @ResponseBody
    public Result comment(HttpServletRequest request, @RequestBody GoodsCommentDTO params) {
        Result result = new Result();
        try {

            WebUser member = Securitys.user(request);

            GoodsComment comment = new GoodsComment();
            comment.setGoods(queryChannelService.findOne(QGoods.goods.id.eq(params.getId()), Goods.class));
            comment.setStarLever(params.getStarLever());
            comment.setContent(params.getContent());
            comment.setPlatformType(0);

            List<GoodsCommentImage> images = Lists.newArrayList();
            for (GoodsCommentImageDTO item : params.getImages()) {
                GoodsCommentImage image = new GoodsCommentImage();
                image.setName(item.getName());
                images.add(image);
            }

            comment.setImages(images);

            OrderDetail orderDetail = queryChannelService.findOne(QOrderDetail.orderDetail.id.eq(params.getOrderDetailId()), OrderDetail.class);

            orderApplication.comment(member, comment, orderDetail);

            return result.ok();

        } catch (IllegalArgumentException e) {
            return result.fail().setMsg(e.getMessage());
        } catch (Exception e) {
            log.error("[获取商品详情异常]", e);
            return result.fail().setMsg("网络连接失败");
        }

    }

    /**
     * 评论列表
     */
    @GetMapping("/comments")
    @ResponseBody
    public Result comments(@RequestParam(defaultValue = "1") int pageNo, @RequestParam(defaultValue = "20") int pageSize, @RequestParam(defaultValue = "0") long id) {
        Result result = new Result();
        try {
            QueryPageRequest pageRequest = new QueryPageRequest().setPageNo(pageNo).setPageSize(pageSize);
            Map<String, Object> params = Maps.newHashMap();
            params.put("id", id);

            String hql = "select c from GoodsComment c where c.platformType = 0 and c.status = 2 and c.goods.id = :id order by c.createTime desc ";
            QueryPage<GoodsComment> page = queryChannelService.findPage(hql, pageRequest.setParams(params), GoodsComment.class);

            for (GoodsComment comment : page.getResult()) {
                Securitys.cleanUser(comment.getMember());
                for (GoodsCommentImage detail : comment.getImages()) {
                    detail.setName(storeDomain + "/uploads/" + detail.getName());
                }
            }

            return result.ok().inject(ImmutableMap.of("page", page));

        } catch (Exception e) {
            log.error("[评论列表异常]", e);
            return result.fail().setMsg("网络请求异常");
        }
    }


}
